import sys
import unittest

from twill.parse import execute_string

from testgen.twillshell import getTwillShellCommands
from testgen.handler import TwillUnitHandler as UnitTestHandler

class TwillUnitTest(UnitTestHandler):
    """

    """
    def testScript(self):
        script = getTwillShellCommands(self.sourceFilename)
        execute_string(script)

if __name__ == "__main__":
    filename = sys.argv[1]
    # unittest does some funky stuff with argv apparently....
    sys.argv = sys.argv[:1]
    loader = unittest.TestLoader()
    test = ZopeTestBrowserUnitTest
    test.sourceFilename = filename
    suite = loader.loadTestsFromTestCase(test)
    suite = unittest.TestSuite(suite)
    unittest.TextTestRunner().run(suite)

